import java.lang.*;
import java.io.*;
public class InvUpdate
{
        
   private InputStreamReader ir=new InputStreamReader(System.in);
	private BufferedReader br,br1;
	private FileOutputStream fos;
	private	PrintStream ps; 
	private FileReader frs; 
        
        String id[]=new String[20];
        int stock[]=new int[20];
        double price[]=new double[20];
        int rol[]=new int[20];
        String name[]=new String[20],s;  
        String cline[]=new String[10];
        String sname[]=new String[20];
    

        
         public void transaction(String name1[],int s1[],int j)
              {
                	
                                int id1[]= new int[20],i=0,total=0;
                                try
                             {
                                frs=new FileReader("InventoryItem.txt");
                               br=new BufferedReader(frs);
                               while((s=br.readLine()) != null)
			      {
                                  total=total+1;
			          cline=s.split(",");
                                  System.out.println("raj");
                                  id[i]=cline[0];
                                  name[i]=cline[1];
                                  sname[i]=cline[2];
                                  stock[i]=Integer.parseInt(cline[4]);
                                  rol[i]=Integer.parseInt(cline[5]);
                                  price[i]=Double.parseDouble(cline[3]);
                                                                i++;
			        }
                              System.out.println("ivalk:"+i);
                              for(int k=0;k<i;k++)
                                  for(int l=0;l<j;l++)
                                  {
                                    if(name[k].equals(name1[l]))
                                     {
                                       stock[k]=stock[k]-s1[k];//""+id1[k];
                                       System.out.println("name:"+name1[k]+" "+stock[k]);
                                      }
                                   }
                                update(id,name,sname,price,stock,rol,i);   
                             
                             }
 		        catch(Exception ex)
 		         {
 			   System.out.println("Error in accepting item specifications...");
 		         }                                   
                                                     
               }                  
                                   
                 public void update(String id[],String name[],String sname[],double price[],int stock[],int rol[],int i) 
                      { 
                          String s="InventoryItem.txt";
                        try
                          {
                              
                               fos=new FileOutputStream("InventoryItem.txt",false);
			       ps=new PrintStream(fos);
                         
                               for(int k=0;k<i;k++)
			       ps.println(id[k]+","+name[k]+","+sname[k]+","+price[k]+","+stock[k]+","+rol[k]);
                            }
			   catch(Exception ex)
 	                	{
 			         System.out.println("Error in accepting item specifications...");
 		                }                                   
                         }
	  

}
